function avg_acc = test_gogo_norm(X1train, X2train, ytrain, ...
                                  gidtrain)
% TEST_GOGO_NORM - calculates 3-fold avg accuracy for the 3 train groups.
    avg_acc = 0;
    for gid=1:3
        % generate test data
        [hellinger_tr_data, ~, hellinger_te_data, ~] =  gen_splitted_data(X1train, ...
                                                                    X2train, ...
                                                                    ytrain, ...
                                                                    gidtrain, ...
                                                                    gid, ...
                                                                    'hellinger');
        [L2_tr_data, ~, L2_te_data, ~] =  gen_splitted_data(X1train, ...
                                                                    X2train, ...
                                                                    ytrain, ...
                                                                    gidtrain, ...
                                                                    gid, ...
                                                                    'L2');
        [L1_tr_data, tr_label, L1_te_data, te_label] =  gen_splitted_data(X1train, ...
                                                                    X2train, ...
                                                                    ytrain, ...
                                                                    gidtrain, ...
                                                                    gid, ...
                                                                    'L1');
        % normalize the data to [-1,1]. Test is normalized according to
        % train data.
        [hellinger_tr_data, norm_params] = norm_data(hellinger_tr_data);
        [hellinger_te_data, ~] = norm_data(hellinger_te_data, norm_params);

        [L1_tr_data, norm_params] = norm_data(L1_tr_data);
        [L1_te_data, ~] = norm_data(L1_te_data, norm_params);

        [L2_tr_data, norm_params] = norm_data(L2_tr_data);
        [L2_te_data, ~] = norm_data(L2_te_data, norm_params);
        
        dataFeatures = [hellinger_tr_data L1_tr_data L2_tr_data];
        dataclass = tr_label;
        testdata = [hellinger_te_data L1_te_data L2_te_data];

        [classestimate,model]=adaboost('train',dataFeatures,dataclass,50);
        
        testclass=adaboost('apply',testdata,model);
        
        acc = 100*((length(find(testclass==te_label)))/(length(te_label)));
        avg_acc = avg_acc + acc;
    end
    avg_acc = avg_acc/3;
    fprintf('Accuracy achieved is %f\n', avg_acc);
end

